package com.bhs.sansonglogistics.ui.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.ChatBean;
import com.bhs.sansonglogistics.bean.PictureBean;
import com.bhs.sansonglogistics.utils.SharedPreferencesUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class ChatAdapter extends BaseMultiItemQuickAdapter<ChatBean, BaseViewHolder> {

    private final String face;

    public ChatAdapter() {
        super(null);
        addItemType(ChatBean.TYPE_RECEIVED_TEXT, R.layout.received_text);
        addItemType(ChatBean.TYPE_SENT_TEXT, R.layout.sent_text);
        face=SharedPreferencesUtils.getString(mContext,"face");
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ChatBean item) {
        helper.setText(R.id.tv_text,item.getText());
        if(item.getItemType()==ChatBean.TYPE_SENT_TEXT){
            Glide.with(mContext).load(face).into((ImageView) helper.getView(R.id.iv_face));
        }else {
            Glide.with(mContext).load(item.getFace()).into((ImageView) helper.getView(R.id.iv_face));
        }

    }
}
